home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8289 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: shell.portal.com!not-for-mail
  2. From: rfield@shell.portal.com (Field)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: float....question
  5. Date: 16 Feb 1996 08:04:21 -0800
  6. Organization: Portal Communications (shell)
  7. Message-ID: <4g29u5$ovk@jobe.shell.portal.com>
  8. References: <4f7obh$lej@wumpus.cc.uow.edu.au> <311D6971.6993@cnw.com>
  9. NNTP-Posting-Host: jobe.shell.portal.com
  10.  
  11. Mike Robinson <miker@cnw.com> writes:
  12.  
  13. >PAOPENG THEERADECH wrote:
  14.  
  15. >> 
  16. >> When I type 5.5 in, I got the output as 5.49999999
  17. >> The number that i got from that program very close to the number that I just
  18. >> type in. Anyway, that not the number that I expect to got.
  19. >> 
  20. >> Could anyone here please kind to tell me what wrong with this?????
  21. >> 
  22.  
  23.  
  24.  
  25. >I just copied your code into my compiler, and it ran fine.  I entered 
  26. >5.5 and it returned 5.5.
  27.  
  28.  
  29. This will depend on the type of rounding done by the compiler and
  30. will vary from implementation to implementation, and these kinds of
  31. problems are common. I have read of compilers (not modern ones) which
  32. would print out integers as fractions, read 2.0, print 1.99999999.
  33. So this looks like a bug in the cout implementation.
  34.